package it.lorenz.server.fk.business;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class SequentialBusinessProcess implements IBusinessProcess {

    private List<? extends IService> services;
    private Iterator<? extends IService> serviceIterator;

    public SequentialBusinessProcess(IService service) {
        setServices(Arrays.asList(service));
    }

    public SequentialBusinessProcess(List<? extends IService> services) {
        setServices(services);
    }

    private void setServices(List<? extends IService> services) {
        this.services = services;
        reset();
    }

    @Override
    public IService next() {
        return serviceIterator.next();
    }

    @Override
    public boolean hasNext() {
        return serviceIterator.hasNext();
    }

    @Override
    public void reset() {
        this.serviceIterator = services.iterator();
    }

}
